/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	ComponentContainer.h
*
*	Description -	Container for storing components
*
*	Comments	-
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	06/15/2012	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_COMPONENT_CONTAINER_H_
#define _PSX_COMPONENT_CONTAINER_H_

#include "PulseSTD.h"
//#include "IComponent.h"
#include "ComponentTypes.h"
#include "Map.h"
#include "Array.h"
#include "StringID.h"
#include "HashTable.h"
#include "XMLParser.h"

namespace Pulse
{
	class ComponentContainer
	{
	public:

		ComponentContainer( void );

		virtual ~ComponentContainer( void );

		virtual void Update( FLOAT dt );

		const SIZE_T GetNumComponents( void ) const { return m_components.GetSize(); }

		IComponent * GetComponent( const SIZE_T index ) { return m_components[index]; }

		IComponent * AddComponent( EComponent::Type type, Actor *pOwner, XMLElementPtr pElem = PSX_NULL );

		IComponent * GetComponent( EComponent::Type componentType );

		IComponent * GetComponent( const CHAR *pName );

		IComponent * GetComponent( EComponent::Type componentType, const CHAR *pName );

		BOOL RemoveComponent( EComponent::Type componentType );

		BOOL RemoveComponent( EComponent::Type componentType, const CHAR *pName );

		void ClearComponents( void );

	private:

		// This container can have the ability to store multiple components of
		//	the same types with different name.

		typedef Array<IComponent*> ComponentList;
		typedef Map< INDEX_T, IComponent * > ComponentMapping;
		
		ComponentMapping	m_componentMap;
		ComponentList		m_components;

	};
}

#endif /* _PSX_COMPONENT_CONTAINER_H_ */
